    /*******************************************************************************
         *
         *    Copyright (c) Baina Info Tech Co. Ltd
         *
         *    Timer TurnOff
         *    
         *    BluetoothControl20
         *    TODO File description or class description.
         *
         *    @author: zuochen
         *    @since:  2011-10-9
         *    @version: 1.0
         *
         ******************************************************************************/

package com.sdk.hardware.manager;

import android.bluetooth.BluetoothAdapter;

/**
 * BluetoothControl20 of Timer TurnOff.
 * @author zuochen
 *
 */

public class BluetoothControl20 implements BluetoothControl{
	// BT state abstraction
	public static int BLUETOOTH_STATE_UNKNOWN;
	public static int BLUETOOTH_STATE_OFF;
	public static int BLUETOOTH_STATE_TURNING_ON;
	public static int BLUETOOTH_STATE_ON;
	public static int BLUETOOTH_STATE_TURNING_OFF;
	public static String BLUETOOTH_ACTION_STATE_CHANGED;
	public static String BLUETOOTH_EXTRA_STATE;

	
	
	private final BluetoothAdapter mAdapter;

	public BluetoothControl20() {
		// cache adaptor
		mAdapter = BluetoothAdapter.getDefaultAdapter();

		if (mAdapter == null)
			throw new UnsupportedOperationException(
					"No default bluetooth adapter");

		// initialize state
		BLUETOOTH_STATE_UNKNOWN = -1;
		BLUETOOTH_STATE_OFF = BluetoothAdapter.STATE_OFF;
		BLUETOOTH_STATE_TURNING_ON = BluetoothAdapter.STATE_TURNING_ON;
		BLUETOOTH_STATE_ON = BluetoothAdapter.STATE_ON;
		BLUETOOTH_STATE_TURNING_OFF = BluetoothAdapter.STATE_TURNING_OFF;

		BLUETOOTH_ACTION_STATE_CHANGED = BluetoothAdapter.ACTION_STATE_CHANGED;
		BLUETOOTH_EXTRA_STATE = BluetoothAdapter.EXTRA_STATE;
	}

	@Override
	public int getBluetoothState() {
		return mAdapter.getState();
	}

	@Override
	public void setEnabled(boolean enabled) {
		if (enabled) {
			mAdapter.enable();
		} else {
			mAdapter.disable();
		}
	}

}
